#ifndef USRMOTINTF_H
#define USRMOTINTF_H

struct zucmot_status_t;
struct zucmot_command_t;
struct zucmot_config_t;
struct zucmot_debug_t;
struct zucmot_error_t;

#ifdef __cplusplus
extern "C" {
#endif

/* usrmotReadZucmotStatus() gets the status info out of
   the zucmot controller and puts it in arg */
extern int usrmotReadZucmotStatus(zucmot_status_t* s);

/* usrmotReadZucmotConfig() gets the config info out of
   the zucmot controller and puts it in arg */
extern int usrmotReadZucmotConfig(zucmot_config_t* s);

/* usrmotReadZucmotDebug() gets the debug info out of
   the zucmot controller and puts it in arg */
extern int usrmotReadZucmotDebug(zucmot_debug_t* s);

/* usrmotReadZucmotError() gets the earliest queued error string out of
   the zucmot controller and puts it in arg */
extern int usrmotReadZucmotError(unsigned char* type, int* perrcode, char* e);

/* usrmotPrintZucmotStatus() prints the status in s, using which
   arg to select sub-prints */
extern void usrmotPrintZucmotStatus(zucmot_status_t* s, int which);

/* usrmotPrintZucmotConfig() prints the config in s, using which
   arg to select sub-prints */
extern void usrmotPrintZucmotConfig(zucmot_config_t s, int which);

/* usrmotPrintZucmotDebug() prints the debug in s, using which
   arg to select sub-prints */
extern void usrmotPrintZucmotDebug(zucmot_debug_t* s, int which);

/* values returned by usrmotWriteZucmotCommand; negative values
   are all errors */
#define ZUCMOT_COMM_OK 0                  /* went through and honored */
#define ZUCMOT_COMM_ERROR_CONNECT -1      /* can't even connect */
#define ZUCMOT_COMM_ERROR_TIMEOUT -2      /* connected, but send timeout */
#define ZUCMOT_COMM_ERROR_COMMAND -3      /* sent, but can't run command now */
#define ZUCMOT_COMM_SPLIT_READ_TIMEOUT -4 /* can't read without split */
#define ZUCMOT_COMM_INVALID_MOTION_ID -5  /* do not queue a motion id MOTION_INVALID_ID */

/* usrmotWriteZucmotCommand() writes the command to the zucmot process.
   Return values are as per the #defines above */
extern int usrmotWriteZucmotCommand(zucmot_command_t* c);

/* usrmotInit() initializes communication with the zucmot process */
extern int usrmotInit(const char* name);

/* usrmotExit() terminates communication with the zucmot process */
extern int usrmotExit(void);

/* usrmotLoadComp() loads the compensation data in file into the joint */
extern int usrmotLoadComp(int joint, const char* file, int type);

/* usrmotPrintComp() prints the joint compensation data for the specified joint */
extern int usrmotPrintComp(int joint);

/* usrmotGetDIn() get the status of the digital inputs*/
extern int usrmotGetDIn(int type, int id, int* status);

/* usrmotGetDOut() get the status of the digital inputs*/
extern int usrmotGetDOut(int type, int id, int* status);

/* usrmotGetAIn() get the status of the digital inputs*/
extern int usrmotGetAIn(int type, int id, double* aval);

/* usrmotGetAOut() get the status of the digital inputs*/
extern int usrmotGetAOut(int type, int id, double* aval);

extern int usrmotGetAtlJointPose(double* jointPos);

extern int usrmotGetAtlTcpPose(double* tcpPos);

extern int usrmotGetAtlFlangePose(double* flangePos);

extern int get_joint_num();

extern int usrmotGetToolOffsets(double* offsets);

extern int usrmotGetUserOffsets(double* offsets);

extern int usrmotGetClsnSensitivity(int& clsn_sensitivity);

extern int usrmotGetToolPayload(double* payload);

extern int usrmotGetSensorType(int type, double* sensor_value);

extern int usrmotGetTIOSignalValue(const char* sigName, unsigned int* value);

extern int usrmotSetEmergencyStopPaused(unsigned char val);
extern int usrmotGetEmergencyStopPaused();

#ifdef __cplusplus
}
#endif
#endif /* USRMOTINTF_H */
